package com.fh.shop.api.mq.producer;

import com.fh.shop.config.MQConstant;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class Producer {
    @Resource
    private RabbitTemplate rabbitTemplate;

    //生产消息
    public void directProducer(String msg){
        rabbitTemplate.convertAndSend(MQConstant.Direct.EX,MQConstant.Direct.ROUTE_KEY,msg);
    }

    public void fanoutProducer(String msg){
        rabbitTemplate.convertAndSend(MQConstant.Fanout.EX,"",msg);
    }
}
